package com.wawayaya.manager;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.wawayaya.ui.MainActivity;
import com.wawayaya.util.Constants;
import com.wawayaya.util.TLog;
import com.wawayaya.util.UIHelper;

import java.util.Observable;
import java.util.Observer;

import wawayaya.kids_iread.R;

/**
 *  导航栏管理类，观察者模式--观察者
 * Created by David on 2015/11/27.
 *
 * @author David
 */
public class TitleBarManager implements Observer {

    private TitleBarManager() {
    }

    public static TitleBarManager getInstance() {
        return SingletonHolder.instance;
    }

    public static class SingletonHolder {
        private static TitleBarManager instance = new TitleBarManager();
    }

    private  TextView  tvHome;
    private  TextView  tvExplore;
    private  TextView  tvMyLibrary;
    private  TextView  tvSettings;
    private  TextView  tvTeacherParent;

    protected MainActivity mActivity;

    public void init(MainActivity activity) {
        this.mActivity = activity;
        View rlHeader = activity.findViewById(R.id.include_shelf_home_header);
        tvHome = (TextView)rlHeader.findViewById(R.id.tv_home_bar);
        tvExplore = (TextView)rlHeader.findViewById(R.id.tv_explore_bar);
        tvMyLibrary = (TextView)rlHeader.findViewById(R.id.tv_mylibrary_bar);
        tvSettings = (TextView)rlHeader.findViewById(R.id.tv_setting_bar);
        tvTeacherParent = (TextView)rlHeader.findViewById(R.id.tv_teacher_parent);

    }

    @Override
    public void update(Observable observable, Object data) {
        // 控制底部导航栏变动

    }

    public void   showParentTeacher(int role){
        TLog.log("当前的角色=："+role);
       String  str="";
        if(role== Constants.roleTeacher){
            tvTeacherParent.setVisibility(View.VISIBLE);
            str = mActivity.getString(R.string.shelf_teacher_teacher);
        }else  if(role== Constants.roleParent){
            tvTeacherParent.setVisibility(View.VISIBLE);
            str=mActivity.getString(R.string.shelf_teacher_parent);
        }else if(role== Constants.roleDefault){
            tvTeacherParent.setVisibility(View.GONE);
        }
        tvTeacherParent.setText(str);
    }

}
